let updata_item_name = '';
let updata_item_state = '';
let app = new Vue({
	el:'.app',
	data:{
		total:'',
		size:5,
		curr:1,
		xiaoshi:false,
		updataxiaoshi:false,
		add_name:'',
		add_price:'',
		add_format:'',
		add_total:'',
		add_inventory:'',
		updata_name:'',
		updata_state:'',
		list:[],
		ids:[]
	},
	created:function(){
		this.getList()
	},
	computed:{
		pagenum:function(){
			return Math.ceil(this.total / this.size)
		}
	},
	methods:{
		getList:function(){
			axios.get('http://chonghekj.com/crud/index.php/Home/Index/getItemList', {
				params:{
					pageSize:this.size,
					pageNumber:this.curr,
					item_name:this.updata_name,
					item_state:this.updata_state,
				}
			})
			.then((res) =>{
				this.list = res.data.rows;
				this.total = res.data.total;
			})
		},
		getpagenum:function(curr){
			this.curr = curr
			this.getList()
		},
		getpageupdata:function(){
			this.curr == 1
			this.getList()
		},
		addInformation:function(){
			this.xiaoshi = true
		},
		// 添加
		determine:function(){
			axios.post('http://chonghekj.com/crud/index.php/Home/Index/addItem',Qs.stringify({
				item_name:this.add_name,
				item_price:this.add_price,
				item_format:this.add_format,
				item_total:this.total,
				item_inventory:this.add_inventory
			}))
			.then((res)=>{
				this.getList()
			})
		},
		// 修改
		updataInformation:function(){
			if(this.ids.length == 1){
				this.updataxiaoshi = true
			}else{
				alert('不要多选')
			}
		},
		// 查询
		getstate:function(){
			console.log(1)
			updata_item_name = this.updata_name,
			updata_item_state = this.updata_state
			this.getList()
		},
		// 删除
		deleInformation:function(){
			axios.post('http://chonghekj.com/crud/index.php/Home/Index/deleteItem',Qs.stringify({
				ids:this.ids
			}))
			.then((res) =>{
				this.getList()
				ids = []
			})
		}
	},
	
})